import { create } from 'zustand';

export type ActiveEvent = string | number | null;

interface FreightStore {
  /**
   * 是否已启动
   */
	isStart: boolean;
  /**
   * 当前选中的图表事件
   */
	activeEvent: ActiveEvent;
  /**
   * 设置是否已启动
   * @param isStart 
   */
  setStart: (isStart: boolean) => void;
  /**
   * 设置当前选中的图表事件
   * @param active 
   */
  setActiveEvent: (active: ActiveEvent) => void;
}

/**
 * 指数图表状态管理
 */
const useFreightStore = create<FreightStore>((set, get) => {
	return {
		isStart: false,
    activeEvent: null,
    setActiveEvent(activeEvent: ActiveEvent) {
			set({
				activeEvent
			});
		},
    setStart(isStart: boolean) {
			set({
				isStart
			});
		}
	};
});

export default useFreightStore;